package app.data.context;

import app.data.CardData;
import org.ricks.agent.DataAgent;
import org.ricks.ioc.Bean;
import org.ricks.ioc.Init;
import org.ricks.log.Logger;
import java.util.HashMap;
import java.util.Map;

/**
 * @author chenwei
 * @date 2022/9/616:55
 */
@Bean
public class DataContext implements Init {

    private static Map<Integer, CardData> cardContext = new HashMap();

    @Override
    public void init() {
        cardContext = DataAgent.getBeanMap(CardData.class);
        cardContext.forEach((k,v) -> Logger.info("cardId: {} and cardBaseId: {}",v.getCardId() , v.getCardBaseId()));
    }

    public static CardData getCard(int cardId) {
        return cardContext.get(cardId);
    }
}
